/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * SummaryPanel.java
 *
 * Created on Nov 7, 2010, 5:17:56 PM
 */

package lmclogistics;

import components.Dates;
import components.Lightbox;
import components.NButton;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JPanel;

/**
 *
 * @author Sonia Tan
 */
public class OCAllPanel extends javax.swing.JPanel {

    /** Creates new form SummaryPanel */

    private int j = 0;
    private JPanel pl;
    private Dates date;
   

    public OCAllPanel() {
        initComponents();
        setOpaque(false);
        setLocation(613, 165);
        setSize(287, 375);
        setLayout(null);
        initPanel();
    }

    public void initPanel(){

            final NButton ok;
            final NButton back;


           
            date = new Dates(1);
            date.initMonth(200, 70, 0, 0);
            date.setM();

            
            pl = date;
            pl.setLocation(0,0);
            add(pl,0);

            repaint();
            ok = new NButton("Ok",135,55);
            back = new NButton("Back",15,55);
            add(ok);
            add(back);

            

            back.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        remove(pl);
                        remove(ok);
                        remove(back);
                        setDefault();
                        repaint();
                    }
            });

            ok.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {

                       if(date.checkMY() == true)
                       {
                           Login.setDescription("");

                           remove(pl);
                           remove(ok);
                           remove(back);


                           int mon, year;

                           mon = date.getMonth();
                           year = date.getYear();


                           setSize(919,577);
                           setLocation(0,0);

                           OCAll oc = new OCAll(mon,year);

                           Main.login.disableButtons();

                            pl = new Lightbox(oc);
                            add(pl, 0);
                            NButton close = new NButton("Close",740,480);
                            pl.add(close,0);
                            close.addActionListener(new ActionListener(){
                                public void actionPerformed(ActionEvent e) {
                                remove(pl);
                                setDefault();
                                repaint();
                                Main.login.enableButtons();
                                }

                            });
                       }
                       else
                           Login.setDescription("Please input valid dates.");
            }
        });

              
}






     public void setDefault(){
            setLocation(613, 165);
            setSize(287, 375);
      
        }

    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        setLayout(null);
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables

}
